<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Class Ad
 * @package App\Models
 * @mixin \Eloquent
 */
class Ad extends Model
{


    protected $table = 'ad';


    public function ad_position()
    {
        return $this->belongsTo(AdPosition::class, 'ad_position_name', 'ad_name');
    }

    public function getPicAttribute($key)
    {
        return config('admin.upload.host') . $key;
    }

    public function getPicStyleAttribute($key)
    {
        if ($key == 'null') {
            return "";
        } else {
            return $key;
        }
    }


    public static function adStyle()
    {
        return [
            'null' => '无样式',
            '_20x20' => '20x20',
            '_750x290' => '750x290',
            '_w600' => 'w600',
            '_w800' => 'w800',
            '_200x200' => '200x200',
            '_120x120' => '120x120',
        ];
    }

    public static function adStatus()
    {
        $status = [
            'on' => ['value' => 1, 'text' => '启用', 'color' => 'primary'],
            'off' => ['value' => 0, 'text' => '禁用', 'color' => 'default'],
        ];

        return $status;
    }

}
